package com.zhuhjay.service.system.model.vo;

import com.zhuhjay.common.base.util.BeanBuilder;
import com.zhuhjay.service.system.model.entity.SystemLog;
import lombok.Data;

import java.util.Date;

/**
 * @author ZhuHJay
 * @date 2023/8/17 22:40
 */
@Data
public class LogVo {

    private Integer id;
    private String methodName;
    private String methodDesc;
    private String requestMethod;
    private String requestUsername;
    private String requestUrl;
    private String requestIp;
    private String requestLocation;
    private String requestData;
    private String responseResult;
    private Integer responseCode;
    private Integer processTime;
    private Date createTime;

    public static LogVo of(SystemLog log, String username) {
        return BeanBuilder.builder(LogVo::new)
                .with(LogVo::setId, log.getId())
                .with(LogVo::setMethodName, log.getMethodName())
                .with(LogVo::setMethodDesc, log.getMethodDesc())
                .with(LogVo::setRequestMethod, log.getRequestMethod())
                .with(LogVo::setRequestUsername, username)
                .with(LogVo::setRequestUrl, log.getRequestUrl())
                .with(LogVo::setRequestIp, log.getRequestIp())
                .with(LogVo::setRequestLocation, log.getRequestLocation())
                .with(LogVo::setRequestData, log.getRequestData())
                .with(LogVo::setResponseResult, log.getResponseResult())
                .with(LogVo::setResponseCode, log.getResponseCode())
                .with(LogVo::setProcessTime, log.getProcessTime())
                .with(LogVo::setCreateTime, log.getCreateTime())
                .build();
    }

}
